package com.ysdwl.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysdwl.model.Provider;
import com.ysdwl.model.User;
import com.ysdwl.service.impl.ProviderService;
import com.ysdwl.service.impl.UserService;

@WebServlet(urlPatterns = "/userList")
public class userListServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
			UserService userService = new UserService();
			List<User> list = userService.findAll(null);
			
			//System.out.println(list);
			req.setAttribute("userList", list);
			
			req.getRequestDispatcher("userList.jsp").forward(req, resp);
			
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}
	
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
	
}
